<script setup>
import ueMsg from '/public/js/app.js'
import api from '@/api'
import { onMounted } from 'vue';

const dataInit = async () => {
  const { data: { layerList } } = await api.getAvailable()
  const { layerLineData, layerPosData, width, height } = layerList[0]
  const lines = JSON.parse(layerLineData)
  const nodes = JSON.parse(layerPosData)
  const sameCurrent = [...new Set(lines.map(item => item.source))]
  const LineProperty = sameCurrent.map(item => ({
    CurrentID: item,
    MappingRelationIDs: lines.filter(ele => ele.source === item).map(ele => ele.target)
  }))
  const UpdataGlopt = {
    "IconProperty": nodes.map(item => ({
      "TopologyIconID": item.id,
      "TopologyIconType": item.img.split('/').pop().split('.').shift(),
      "X": item.x / Number(width),
      "Y": item.y / Number(height),
    })),
    LineProperty
  }
}
onMounted(() => {
  dataInit()
})
</script>

<template>
  <div></div>
</template>